package cn.connectivity.plugin.gui;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class ConnectivityToolWindowFactory implements ToolWindowFactory {
    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        SettingsForm settingsForm = new SettingsForm(project, toolWindow);
        JPanel rootPanel = settingsForm.getRootPanel();
        // 获取内容工厂实例
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        // 构建toolWindow显示内容
        Content content = contentFactory.createContent(rootPanel, "", false);
        // 给toolWindow设置显示内容
        toolWindow.getContentManager().addContent(content);
    }
}
